﻿using System;
using System.Collections.Generic;

namespace Terraria.UI.Gamepad
{
	// Token: 0x02000124 RID: 292
	public class UILinkPage
	{
		// Token: 0x14000024 RID: 36
		// (add) Token: 0x06000CC1 RID: 3265 RVA: 0x003F554C File Offset: 0x003F374C
		// (remove) Token: 0x06000CC2 RID: 3266 RVA: 0x003F5584 File Offset: 0x003F3784
		public event Action<int, int> ReachEndEvent;

		// Token: 0x14000025 RID: 37
		// (add) Token: 0x06000CC3 RID: 3267 RVA: 0x003F55BC File Offset: 0x003F37BC
		// (remove) Token: 0x06000CC4 RID: 3268 RVA: 0x003F55F4 File Offset: 0x003F37F4
		public event Action TravelEvent;

		// Token: 0x14000026 RID: 38
		// (add) Token: 0x06000CC5 RID: 3269 RVA: 0x003F562C File Offset: 0x003F382C
		// (remove) Token: 0x06000CC6 RID: 3270 RVA: 0x003F5664 File Offset: 0x003F3864
		public event Action LeaveEvent;

		// Token: 0x14000027 RID: 39
		// (add) Token: 0x06000CC7 RID: 3271 RVA: 0x003F569C File Offset: 0x003F389C
		// (remove) Token: 0x06000CC8 RID: 3272 RVA: 0x003F56D4 File Offset: 0x003F38D4
		public event Action EnterEvent;

		// Token: 0x14000028 RID: 40
		// (add) Token: 0x06000CC9 RID: 3273 RVA: 0x003F570C File Offset: 0x003F390C
		// (remove) Token: 0x06000CCA RID: 3274 RVA: 0x003F5744 File Offset: 0x003F3944
		public event Action UpdateEvent;

		// Token: 0x14000029 RID: 41
		// (add) Token: 0x06000CCB RID: 3275 RVA: 0x003F577C File Offset: 0x003F397C
		// (remove) Token: 0x06000CCC RID: 3276 RVA: 0x003F57B4 File Offset: 0x003F39B4
		public event Func<bool> IsValidEvent;

		// Token: 0x1400002A RID: 42
		// (add) Token: 0x06000CCD RID: 3277 RVA: 0x003F57EC File Offset: 0x003F39EC
		// (remove) Token: 0x06000CCE RID: 3278 RVA: 0x003F5824 File Offset: 0x003F3A24
		public event Func<bool> CanEnterEvent;

		// Token: 0x1400002B RID: 43
		// (add) Token: 0x06000CCF RID: 3279 RVA: 0x003F585C File Offset: 0x003F3A5C
		// (remove) Token: 0x06000CD0 RID: 3280 RVA: 0x003F5894 File Offset: 0x003F3A94
		public event Func<string> OnSpecialInteracts;

		// Token: 0x06000CD1 RID: 3281 RVA: 0x0000CEFA File Offset: 0x0000B0FA
		public UILinkPage()
		{
		}

		// Token: 0x06000CD2 RID: 3282 RVA: 0x0000CF1B File Offset: 0x0000B11B
		public UILinkPage(int id)
		{
			this.ID = id;
		}

		// Token: 0x06000CD3 RID: 3283 RVA: 0x0000CF43 File Offset: 0x0000B143
		public void Update()
		{
			if (this.UpdateEvent != null)
			{
				this.UpdateEvent();
			}
		}

		// Token: 0x06000CD4 RID: 3284 RVA: 0x0000CF58 File Offset: 0x0000B158
		public void Leave()
		{
			if (this.LeaveEvent != null)
			{
				this.LeaveEvent();
			}
		}

		// Token: 0x06000CD5 RID: 3285 RVA: 0x0000CF6D File Offset: 0x0000B16D
		public void Enter()
		{
			if (this.EnterEvent != null)
			{
				this.EnterEvent();
			}
		}

		// Token: 0x06000CD6 RID: 3286 RVA: 0x0000CF82 File Offset: 0x0000B182
		public bool IsValid()
		{
			return this.IsValidEvent == null || this.IsValidEvent();
		}

		// Token: 0x06000CD7 RID: 3287 RVA: 0x0000CF99 File Offset: 0x0000B199
		public bool CanEnter()
		{
			return this.CanEnterEvent == null || this.CanEnterEvent();
		}

		// Token: 0x06000CD8 RID: 3288 RVA: 0x0000CFB0 File Offset: 0x0000B1B0
		public void TravelUp()
		{
			this.Travel(this.LinkMap[this.CurrentPoint].Up);
		}

		// Token: 0x06000CD9 RID: 3289 RVA: 0x0000CFCE File Offset: 0x0000B1CE
		public void TravelDown()
		{
			this.Travel(this.LinkMap[this.CurrentPoint].Down);
		}

		// Token: 0x06000CDA RID: 3290 RVA: 0x0000CFEC File Offset: 0x0000B1EC
		public void TravelLeft()
		{
			this.Travel(this.LinkMap[this.CurrentPoint].Left);
		}

		// Token: 0x06000CDB RID: 3291 RVA: 0x0000D00A File Offset: 0x0000B20A
		public void TravelRight()
		{
			this.Travel(this.LinkMap[this.CurrentPoint].Right);
		}

		// Token: 0x06000CDC RID: 3292 RVA: 0x0000D028 File Offset: 0x0000B228
		public void SwapPageLeft()
		{
			UILinkPointNavigator.ChangePage(this.PageOnLeft);
		}

		// Token: 0x06000CDD RID: 3293 RVA: 0x0000D035 File Offset: 0x0000B235
		public void SwapPageRight()
		{
			UILinkPointNavigator.ChangePage(this.PageOnRight);
		}

		// Token: 0x06000CDE RID: 3294 RVA: 0x003F58CC File Offset: 0x003F3ACC
		private void Travel(int next)
		{
			if (next < 0)
			{
				if (this.ReachEndEvent != null)
				{
					this.ReachEndEvent(this.CurrentPoint, next);
					if (this.TravelEvent != null)
					{
						this.TravelEvent();
						return;
					}
				}
			}
			else
			{
				UILinkPointNavigator.ChangePoint(next);
				if (this.TravelEvent != null)
				{
					this.TravelEvent();
				}
			}
		}

		// Token: 0x06000CDF RID: 3295 RVA: 0x0000D042 File Offset: 0x0000B242
		public string SpecialInteractions()
		{
			if (this.OnSpecialInteracts != null)
			{
				return this.OnSpecialInteracts();
			}
			return string.Empty;
		}

		// Token: 0x04001157 RID: 4439
		public int ID;

		// Token: 0x04001158 RID: 4440
		public int PageOnLeft = -1;

		// Token: 0x04001159 RID: 4441
		public int PageOnRight = -1;

		// Token: 0x0400115A RID: 4442
		public int DefaultPoint;

		// Token: 0x0400115B RID: 4443
		public int CurrentPoint;

		// Token: 0x0400115C RID: 4444
		public Dictionary<int, UILinkPoint> LinkMap = new Dictionary<int, UILinkPoint>();
	}
}
